<!DOCTYPE html>
<html lang="en">
<head th:include="include :: header"></head>
<body>
    <!-- 为ECharts准备一个具备大小（宽高）的Dom -->
    <div class="row">
        <div class="col-md-6" id="main" style="width: 50%;height:500px;"></div>
        <div class="col-md-6" id="company" style="width: 50%;height:500px;"></div>
    </div>
    <div class="row">
        <div class="col-md-6" id="interview" style="width: 50%;height:500px;"></div>
    </div>



    <div th:include="include :: footer"></div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
        $(document).ready(function(){
            $.ajax({
                url: "/statistics/getStatistics",
                type: "get",
                success: function (res){
                    var data = []
                    var i = 0;
                    var companyCount = 0;
                    for (var key in res) {
                        if(key != 'msg' && key != 'code' ){
                            if(key == 'company2Count' || key == 'company1Count' || key == 'company3Count'){
                                companyCount += res[key];
                            }else{
                                data[i] = res[key]
                                i++;
                            }
                        }
                    }
                    data[i] = companyCount;
                    // 基于准备好的dom，初始化echarts实例
                    var myChart = echarts.init(document.getElementById('main'));

                    // 指定图表的配置项和数据
                    var option = {
                        title: {
                            text: '数据统计'
                        },
                        tooltip: {},
                        legend: {
                            data:['数量']
                        },
                        xAxis: {
                            data: ["求职者","在招职位","所有公司"]
                        },
                        yAxis: {},
                        series: [
                            {
                                name: '数量',
                                type: 'bar',
                                data: data
                            },
                        ]
                    };
                    // 使用刚指定的配置项和数据显示图表。
                    myChart.setOption(option);



                    //公司图
                    var data = []
                    for (var key in res) {
                        if(key == 'company1Count'){
                            data[0] = res[key]
                        }
                        if(key == 'company2Count'){
                            data[1] = res[key]
                        }
                        if(key == 'company3Count'){
                            data[2] = res[key]
                        }

                    }
                    console.log(data)
                    // 基于准备好的dom，初始化echarts实例
                    var myChart = echarts.init(document.getElementById('company'));

                    // 指定图表的配置项和数据
                    var option = {
                        title: {
                            text: '公司认证情况'
                        },
                        tooltip: {},
                        legend: {
                            data:['数量']
                        },
                        xAxis: {
                            data: ["审核通过","审核不通过","待审核"]
                        },
                        yAxis: {},
                        series: [
                            {
                                name: '数量',
                                type: 'bar',
                                data: data
                            },
                        ]
                    };
                    // 使用刚指定的配置项和数据显示图表。
                    myChart.setOption(option);


                    //求职者
                    var data = []
                    for (var key in res) {
                        if(key == 'i1'){
                            data[0] = res[key]
                        }
                        if(key == 'i2'){
                            data[1] = res[key]
                        }

                    }
                    console.log(data)
                    // 基于准备好的dom，初始化echarts实例
                    var myChart = echarts.init(document.getElementById('interview'));

                    // 指定图表的配置项和数据
                    var option = {
                        title: {
                            text: '面试情况'
                        },
                        tooltip: {},
                        legend: {
                            data:['数量']
                        },
                        xAxis: {
                            data: ["线下面试","线上面试"]
                        },
                        yAxis: {},
                        series: [
                            {
                                name: '数量',
                                type: 'bar',
                                data: data
                            },
                        ]
                    };
                    // 使用刚指定的配置项和数据显示图表。
                    myChart.setOption(option);
                }
            })

        })
    </script>
</body>
</html>